package anthology.daily_question._25_02;

import java.util.List;

//https://leetcode.cn/problems/maximum-distance-in-arrays/description/?envType=daily-question&envId=2025-02-19
public class _0624数组列表中的最大距离 {
    class Solution {
        public int maxDistance(List<List<Integer>> arrays) {
            List<Integer> array = arrays.get(0);
            int mx = array.get(0);
            int mn = array.get(array.size() - 1);
            int ans = 0;
            for(List<Integer> a : arrays){
                int x = a.get(0);
                int y = a.get(a.size() - 1);
                ans = Math.max(ans, Math.max(y - mn, mx - x));
                mn = Math.min(mn, x);
                mx = Math.max(mx, y);
            }
            return ans;
        }
    }
}
